<template>
  <el-dialog
    @close="close"
    title="提现详情"
    :visible.sync="dialog"
    width="40%"
    style="display:flex;"
  >
    <el-card class="box-card" style="margin-bottom:10px;">
      <div slot="header" class="clearfix">
        <span>申请人信息</span>
      </div>
      <div class="item">用户昵称：{{formInline.truename}} </div>
      <div class="item">用户ID： {{formInline.user_id}}</div>
      <div class="item">手机号： {{formInline.mobile}}</div>
      <div class="item">账号状态：
        <span v-if="moreUser.statustype == 0">
              正常
        </span>
        <span v-else-if="moreUser.statustype == 1">
              锁定
        </span>
        <span v-else-if="moreUser.statustype == 2">
              冻结
        </span>
        <span v-else-if="moreUser.statustype == 10">
              禁用
        </span>
      </div>
      <div class="item">账户余额： {{moreUser.goldnumber}}N豆</div>
    </el-card>
    <el-card class="box-card" style="margin-bottom:10px;">
      <div slot="header" class="clearfix">
        <span>提现信息</span>
      </div>
      <div class="item">提现人姓名： {{formInline.username}}</div>
      <div class="item">身份证号码： {{formInline.identitycard}}</div>
      <div class="item">支付宝账号： {{formInline.account}}</div>
      <div class="item">提现金额： {{formInline.money}}</div>
      <div class="item">手续费： {{formInline.servicecharge}}</div>
      <div class="item">提现状态：
          <span v-if="formInline.embodystatustype == 0">
              未处理
          </span>
          <span v-else-if="formInline.embodystatustype == 1">
              已处理
          </span>
          <span v-else-if="formInline.embodystatustype == 2">
              拒绝
          </span>
      </div>
      <div class="item">申请时间： {{formInline.createtime}}</div>
    </el-card>
    <el-card class="box-card" v-show="formInline.embodystatustype != 0">
      <div slot="header" class="clearfix">
        <span>处理人信息</span>
      </div>
      <div class="item">账号： {{adminLog.account}}</div>
      <div class="item">角色： {{adminLog.role}}</div>
      <div class="item">手机号码： {{adminLog.phone}}</div>
      <div class="item">处理时间： {{adminLog.optime}}</div>
    </el-card>
    <span slot="footer" class="dialog-footer">
      <el-button :disabled="btnLoading" @click="onApplication(1)" >同意提现</el-button>
      <el-button type="primary"  :loading="btnLoading" @click="onSubmit">驳回申请</el-button>
    </span>
  </el-dialog>

</template>
<script>
  import { getWithdrawalMoneyDetailAPI , getAdminLogAPI , applicationAPI } from '@/api/tradingcenter'
  import { getPersonInfoMostAPI } from '@/api/person'
  import RejectReason from './rejectReason'

  // import { getRouterTreeAPI } from '@/api/system/menu'

  export default {
    name: 'WithdrawalApplicationEdit',
    props: {
      dialog_: {
        type: Boolean,
        default: false
      },
      id: {
        type: Number,
        default: null
      },
      user_id: {
        type: Number,
        default: null
      },
      orderno: {
        type: String,
        default: null
      }
    },
    data() {
      return {
        dialog:false,
        formInline:{
          truename:'',
          identitycard:'',
          money:'',
          servicecharge:'',
          account:'',
          user_id:'',
          mobile:'',
          createtime:'',
          embodystatustype:'',
          username:''//真实姓名
        },
        adminLog:{
          order: "",
          operator: 1,
          account: "",
          role: "",
          phone: "",
          optime: ""
        },
        moreUser:{
          goldnumber:'',
          statustype:''
        }
      }
    },
    methods: {
      close() {
        this.$emit('close')
      },
      // 同意或者驳回
      onApplication(status) {  // status:1通过，0驳回
        let param = {
          id: this.id,
          permit:status,
          userid:this.user_id
        }
        applicationAPI(param).then(res => {
          if (res.code === 0) {
            this.$emit('close')
            this.$emit('success')
            this.$message.success('操作成功')
          } else {
            this.$message.error(res.msg)
          }
        })
      },
      // 驳回
      onSubmit() {
        this.$prompt('填写驳回理由', '', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          inputErrorMessage: '字数不能多于20个',
          inputType:'textarea',
          inputPattern: /^\S{1,20}$/
        }).then(({ value }) => {
          let param = {
            id: this.id,
            permit:0,
            userid:this.user_id,
            reason:value
          }
          applicationAPI(param).then(res => {
            if (res.code === 0) {
              this.$emit('close')
              this.$emit('success')
              this.$message.success('操作成功')
            } else {
              this.$message.error(res.msg)
            }
          })
        }).catch(() => {
          /*this.$message({
            type: 'info',
            message: '取消输入'
          });*/
        });
      },
      getDetail(){
        getWithdrawalMoneyDetailAPI({id:this.id}).then(res => {
          this.btnLoading = false
          if (res.code === 0) {
            this.formInline = res.data
          } else {
            this.$message.error(res.message)
          }
        })
      },
      // 查询单个用户的丰富信息
      getUserDetail(){
        getPersonInfoMostAPI({userid:this.user_id}).then(res => {
          this.btnLoading = false
          if (res.code === 0) {
            this.moreUser = res.data
          } else {
            this.$message.error(res.message)
          }
        })
      },
      getLogDetail(){
        getAdminLogAPI({order:this.orderno}).then(res => {
          this.btnLoading = false
          if (res.code === 0) {
            this.adminLog = res.data
          } else {
            this.$message.error(res.msg)
          }
        })
      },
    },
    mounted() {
      this.dialog = this.dialog_
      if (this.id) {
        this.getDetail() // 查询详情
        this.getUserDetail();
        this.getLogDetail();
      } else {
        //this.getRouterAll() //新增查询菜单树信息
      }
    }
  }
</script>
<style scoped>
  .item{
    margin-bottom: 10px;
  }
  /* /deep/.el-dialog__body::after{
    display: block;
    content: '';
    height: 0;
    clear: both;
  } */
</style>

